home *** CD-ROM | disk | FTP | other *** search
/ PD ROM 1 / PD ROM Volume I - Macintosh Software from BMUG (1988).iso / Stacks / Updates⁄New / TEXAS for BMUG / C progs / qndxr.2 ƒ / qndxr.2.h < prev    next >
Encoding:
C/C++ Source or Header  |  1987-11-03  |  4.7 KB  |  154 lines  |  [TEXT/KAHL]

  1. /* header file for project qndxr -- by ^z -- 870820-0913-...
  2.  */
  3.  
  4. /* tell what compiler we're using ... Lightspeed C by Think, if the
  5.  * following line is #defined ... essentially, when LIGHTSPEED is here,
  6.  * assume that we have only 16-bit int variables and that Macintosh
  7.  * toolbox traps are available ... when LIGHTSPEED is not #defined,
  8.  * assume that ints can hold more like 32 bits without error, so more
  9.  * can be done using standard I/O routines from <stdio>
  10.  */
  11. #define LIGHTSPEED
  12.  
  13. /* preprocessor 'function' to turn on/off debug printing of detailed info
  14.  *    during program runs ... when debugging, use a statement:
  15.  * #define DEBUG(fmt, arg)   printf (fmt, arg)
  16.  * ... and when not debugging, just use:  #define DEBUG(fmt, arg)
  17.  * to effectively remove those print commands....
  18.  */
  19. /* #define DEBUG(fmt, arg)   printf (fmt, arg) */
  20. #define DEBUG(fmt, arg)
  21.  
  22. /* sort on KEY_LENGTH characters ... make it 28 rather arbitrarily as an
  23.  * experiment ... want it long enough to avoid truncation of legitimate
  24.  * words, but short enough to save some space in the *.k files ... an
  25.  * alternative value is 12, for compatibility with the older ndxr.c program
  26.  * and brwsr.c, if they haven't been revised to allow for longer keys....
  27.  */
  28. #define KEY_LENGTH  28
  29.  
  30. /* define a structure for the index_keys file
  31.  */
  32. typedef struct
  33.   {
  34.     char kkey[KEY_LENGTH];
  35.     long ccount;
  36.   }  KEY_REC;
  37.  
  38. /* define a structure for my simpleminded I/O buffers ...
  39.  */
  40. typedef struct
  41.   {
  42.     char *zbufbase;
  43.     char *zbufp;
  44.     long zbufcounter;
  45.     long zbufsize;
  46.     FILE *zbuffilep;
  47.     int  zbufitemsize;
  48.   }  ZBUF;
  49.  
  50. /* choose this size to be the default memory size used for total buffer
  51.  * space ... for convenience on the Mac Plus, I have picked 512 kB, which
  52.  * leaves me a bit of space to spare ....
  53.  */
  54. #define DEFAULT_MEMSIZ  524288
  55.  
  56. /* merge this many files at each stage of the merging operation for index
  57.  * building ... 2 means a binary merge, etc. ... one needs to have at least
  58.  * 5 + 2 * NMERGE I/O buffers around:  for each of NMERGE files, there is
  59.  * a *.k keys file and a *.p pointers file; plus there must be a single
  60.  * output *.k and a single output *.p file; plus there is the need for stdin,
  61.  * stdout, and stderr to be open as well.  Thus, I have found that a 4-way
  62.  * merge (NMERGE = 4) works pretty nicely....
  63.  */
  64. #define NMERGE  4
  65.  
  66. #ifndef TRUE
  67. #define TRUE  1
  68. #endif
  69.  
  70. #ifndef FALSE
  71. #define FALSE  0
  72. #endif
  73.  
  74. /* CMASK makes sure that a returned character isn't sign-extended
  75.  */
  76. #ifndef CMASK
  77. #define CMASK  0xFF
  78. #endif
  79.  
  80. /* put the prototypes for my functions here... assume that if LIGHTSPEED
  81.  * is #define'd, then we want to use prototypes....
  82.  */
  83. #ifdef LIGHTSPEED
  84.  
  85. /* in qndxr unix main.c */
  86. void punt(void);
  87. void openfile(FILE *file, char *mode);
  88. void main(void);
  89.  
  90. /* in qndxr.c */
  91. void _main(int argc, char *argv[]);
  92.  
  93. /* in bufio.c */
  94. void create_zbuffer (int n, long bufsize, FILE *buffile, int bufitemsize);
  95. void free_zbuffer (int n);
  96. char *next_input_item (int n);
  97. void load_zbuffer (int n);
  98. char *next_output_item (int n);
  99. void flush_zbuffer (int n);
  100.  
  101. /* in build_indices.c */
  102. int build_indices (void);
  103.  
  104. /* in doc_buf.c */
  105. char *make_buf (long bufsiz);
  106. long load_doc_buffer (char *doc, long doc_bufsiz, char **ptr);
  107. int filtered_getc (void);
  108.  
  109. /* in merge_files.c */
  110. void nway_merge_kpfiles (FILE *ink[], FILE *inp[], FILE *outk, FILE *outp,
  111.         int n);
  112. void copy_ptr_recs (int inzbuf, long count, int outzbuf);
  113. void copy_key_rec (char *kkey, long ccount, int outzbuf);
  114. int merge_not_finished (KEY_REC *kr[], int n);
  115. int smallest_key (KEY_REC *kr[], int n);
  116.  
  117. /* in merge_indices.c */
  118. int merge_indices (char *doc_filename);
  119.  
  120. /* in file_utils.c */
  121. void write_sorted_files (char *doc, char **ptr, long nwords,
  122.         int pass_number, long offset);
  123. int is_new_word (char *w0, char *w1);
  124. void write_new_key (char *p, char *kp);
  125.  
  126. /* in merge_utils.c */
  127. FILE *open_inkfile (int generation_number, int file_number);
  128. FILE *open_inpfile (int generation_number, int file_number);
  129. void fix_oddball_file_name (int generation_number, int file_number);
  130. void fix_final_file_names (int generation_number, char *doc_filename);
  131. FILE *open_outkfile (int generation_number, int file_number);
  132. FILE *open_outpfile (int generation_number, int file_number);
  133. void remove_used_infiles (int generation_number, int file_number, int n);
  134. void close_infiles (FILE *ink[], FILE *inp[], int n);
  135.  
  136. /* in misc_utils.c */
  137. long set_params (int argc, char *argv[]);
  138. long set_zbufsiz (long zb);
  139. void set_parser_options (char *str);
  140. void check_interrupt (void);
  141. long file_size (FILE *fp);
  142.  
  143. /* in open_files.c */
  144. FILE *open_docfile (int argc, char *argv[]);
  145. FILE *open_kfile (int pass_number);
  146. FILE *open_pfile (int pass_number);
  147.  
  148. /* in zqsort.c */
  149. void zqsort (char **first, char **last);
  150. int compare_ptrs (char **p1, char **p2);
  151. int zstrcmp (char *s1, char *s2);
  152.  
  153. #endif
  154.